<?php
/**
 * 网页元素
 *
 * @version        $Id: ad_main.php 1 8:26 2010年7月12日Z tianya $
 * @package        DedeCMS.Administrator
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */

require_once(dirname(__FILE__).'/config.php');
require_once(DEDEINC.'/datalistcp.class.php');
require_once(DEDEINC.'/common.func.php');
setcookie('ENV_GOBACK_URL',$dedeNowurl,time()+3600,'/');
$id = empty($id) ? 0 : intval($id);
if ($dopost == 'detail'){
	$row = $dsql->GetOne("SELECT * FROM `#@__guestbook` where id='$id'");
	$row['dtime'] = date('Y-m-d H:i:s',$row['dtime']);
	include DedeInclude('templets/message_detail.htm');
	exit();
}elseif ($dopost == 'delete'){
    $dsql->ExecuteNoneQuery("DELETE FROM `#@__guestbook` where id='$id' ");
	 ShowMsg("成功删除一则留言！", $ENV_GOBACK_URL);
	 exit();
}elseif ($dopost == 'audit'){
	global $dsql;
	$sql ="update #@__guestbook set isaudit=1 where id=".$id;
	$dsql->ExecuteNoneQuery($sql);
	
	ShowMsg("成功审核一则留言！", $ENV_GOBACK_URL);
	exit();
}

$arctype_id = isset($arctype_id)? intval($arctype_id) : 0;
$title = isset($title)? addslashes($title) : '';
$uname = isset($uname)? addslashes($uname) : '';
$cid = empty($cid) ? 0 : intval($cid);
$where_sql = ' 1 ';
if ($title){
	$where_sql .= " and title like '%".$title."%'";
}
if ($uname){
	$where_sql .=" and uname='".$uname."'";
}

if ($tel){
	$where_sql .= " and tel = '".$tel."'";
}
$sql = "SELECT * FROM `#@__guestbook` WHERE $where_sql ORDER BY id desc";
$dlist = new DataListCP();
$dlist->SetTemplet(DEDEADMIN."/templets/message_main.htm");
$dlist->SetSource($sql);
$dlist->display();
//inc_web::select_position_option($postion)
function geTarctypeName($id){
	global $dsql;
	$row = $dsql->GetOne("SELECT typename FROM `#@__arctype`where  id='$id'");
	return $row['typename'];
}
